package main

import (
	"log"
	"os"
	"math/big"
	"github.com/ethereum/go-ethereum/accounts/abi/bind"
	"github.com/ethereum/go-ethereum/common"
	"github.com/ethereum/go-ethereum/ethclient"
)

func main(){
	//连接geth
	cli, err := ethclient.Dial("http://localhost:8545")
	if err != nil {
		log.Fatal("failed to connto geth", err)
	}
	//获取入口
	instance, err := NewKcc(common.HexToAddress("0x64f547a71a3d461c7a0067535637b13b23b2d74a"), cli)
	if err != nil {
		log.Fatal("failed to new instance", err)
	}
	//生成签名文件
	file, err := os.Open("/home/always/test/geth/data/keystore/UTC--2018-11-11T01-41-43.525023065Z--b146290efddb3eea71bf00340d28fe45e2bca19e")
	if err != nil {
		log.Fatal("failed to open auth file", err)
	}
	auth, err := bind.NewTransactor(file, "")
	if err != nil {
		log.Fatal("failed to NewTransactor", err)
	}
	//转账
	instance.Transfer(auth, common.HexToAddress("0xcfb9a950c15d091548ac4b9817624106844ccb78"), big.NewInt(100))
}
